package com.bmw.redis3.controller;

import com.bmw.redis3.base.BaseResponse;
import com.bmw.redis3.base.ClickRequest;
import com.bmw.redis3.base.RankResp;
import com.bmw.redis3.service.ClickService;
import com.bmw.redis3.service.RankService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * Classname: listController
 * Package: com.bmw.redis3.controller
 * Description:
 *
 * @Author 王少伟
 * @Create 2024/5/24 21:42
 * @Version 1.8
 */
@RestController
@RequestMapping(value = "/rank")
public class listController {
    @Autowired
    RankService rankService;
    @Autowired
    ClickService clickService;

    /**
     * 排行榜
     */

    @RequestMapping("/list")
    public BaseResponse<List<RankResp>> list(){
        return BaseResponse.ok(rankService.list());
    }

    /**
     * 点赞
     */
    @RequestMapping(value = "/click")
    public BaseResponse order(@RequestBody @Valid ClickRequest Req){
        return BaseResponse.OK(clickService.click(Req));
    }
}
